package com.rem.shardingjdbc.config;

import cn.hutool.core.date.DateUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.spi.keygen.ShardingKeyGenerator;
import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * @author Rem
 * @date 2021/6/16
 */
@Component
@Slf4j
@Data
public class KeyGenerator implements ShardingKeyGenerator {

    private Properties properties = new Properties();

    @Override
    public Comparable<?> generateKey() {
        return DateUtil.currentSeconds();
    }

    @Override
    public String getType() {
        return "MYKEY";
    }

}